package com.cms.server.resolver.plugins;

import java.sql.ResultSet;

import com.efounder.builder.base.data.EFDataSet;
import com.efounder.builder.base.data.EFRowSet;
import com.efounder.eai.data.JParamObject;
import com.efounder.form.EFFormDataModel;
import com.efounder.form.io.FormDataResolverAdapter;
import com.efounder.form.server.resolver.util.SYS_MDL_VAL;
import com.efounder.sql.JStatement;
import com.metadata.bizmodel.SYS_MODEL;
import com.persistence.FLOW_TASK_LIST;

public class CMSCheckFlowEnd extends FormDataResolverAdapter {

	//初始化FormDataModel
	public void prepareSaveForm(JStatement stmt, EFFormDataModel model, JParamObject PO) throws Exception {		
		String                            strSql = "";
		ResultSet                             rs = null;
		EFDataSet                            eds = model.getBillDataSet();
		EFRowSet                             ers = eds.getRowSet(0);
	    String                            F_KJQJ = ers.getString(PO.GetValueByParamName(SYS_MODEL._BLFL_KJQJ_COL_, SYS_MDL_VAL.BILL_KJQJ), "");
	    String                            F_DJBH = ers.getString(PO.GetValueByParamName(SYS_MODEL._BILL_BH_COL_, SYS_MDL_VAL.BILL_BH), null);
	    String                           FLOW_ID = PO.GetValueByParamName(FLOW_TASK_LIST._FLOW_ID, "");
	    
		//获取流程节点
		strSql = " select * from FLOW_TASK_LIST where BIZ_DATE = '" + F_KJQJ + "' and BIZ_DJBH = '" + F_DJBH + "' and "
		       + " FLOW_ID = '" + FLOW_ID + "'";
		rs = stmt.executeQuery(strSql);
		
		if(rs != null && rs.next()) {
			throw new Exception("<br>单据还没有结束流程，不能作废！");
		}
	}
}
